clear all

foreach data in $datafiles {

	* Set globals:
		global dataspec `data'
		global n = 2
		global rhs1 diff_ln_IND 
		global rhs2 diff_wIPT_IND_CHN
		global ivs1 diff_ln_IVS 
		global ivs2 diff_wIPT_LMI_CHN_EXCL_IND
		global ctrl 
	do "$code/estimation/flexible/decomp_regs_bs.do"

	* Set globals:
		global dataspec `data'
		global n = 3
		global rhs1 diff_ln_IND 
		global rhs2 
		global ivs1 diff_ln_IVS 
		global ivs2 
		global ctrl diff_wIPT_LMI_CHN_EXCL_IND
	do "$code/estimation/flexible/decomp_regs_bs.do"

	use "$tempfold/bs2_`data'", clear
	merge 1:1 bs using "$tempfold/bs3_`data'", nogen
	save "$tempfold/cbs", replace

	clear
	use "$BS_fold/bs_`data'", clear
	append using "$tempfold/cbs"
	save "$BS_fold/bs_`data'", replace
	
	
	* Set globals:
		global dataspec `data'
		global n = 2
		global rhs1 diff_ln_IND 
		global rhs2 diff_wIPT_IND_CHN
		global ivs1 diff_ln_IVS 
		global ivs2 diff_wIPT_LMI_CHN_EXCL_IND
		global ctrl 
	do "$code/estimation/flexible/decomp_regs_mp_bs.do"

	* Set globals:
		global dataspec `data'
		global n = 3
		global rhs1 diff_ln_IND 
		global rhs2 
		global ivs1 diff_ln_IVS 
		global ivs2 
		global ctrl diff_wIPT_LMI_CHN_EXCL_IND
	do "$code/estimation/flexible/decomp_regs_mp_bs.do"

	use "$tempfold/bs2_`data'", clear
	merge 1:1 bs using "$tempfold/bs3_`data'", nogen
	save "$tempfold/cbs", replace
	
	clear
	use "$BS_fold/bs_`data'_mp", clear
	append using "$tempfold/cbs"
	save "$BS_fold/bs_`data'_mp", replace
	
	* Set globals:
		global dataspec `data'
		global n = 2
		global rhs1 c.diff_ln_IND#size
		global rhs2 c.diff_wIPT_IND_CHN#size
		global ivs1 c.diff_ln_IVS#size
		global ivs2 c.diff_wIPT_LMI_CHN_EXCL_IND#size
		global ctrl 
	do "$code/estimation/flexible/decomp_regs_interactions_bs.do"

	* Set globals:
		global dataspec `data'
		global n = 3
		global rhs1 c.diff_ln_IND#size
		global rhs2 
		global ivs1 c.diff_ln_IVS#size
		global ivs2 
		global ctrl c.diff_wIPT_LMI_CHN_EXCL_IND#size
	do "$code/estimation/flexible/decomp_regs_interactions_bs.do"

	use "$tempfold/bs2_`data'", clear
	merge 1:1 bs using "$tempfold/bs3_`data'", nogen
	save "$tempfold/cbs", replace

	clear
	use "$BS_fold/bsi_`data'"
	append using "$tempfold/cbs"
	save "$BS_fold/bsi_`data'", replace
	
		***************** Interacted By Size (salaries) *****************

	* Set globals:
		global dataspec `data'
		global n = 2
		global rhs1 c.diff_ln_IND#size
		global rhs2 c.diff_wIPT_IND_CHN#size
		global ivs1 c.diff_ln_IVS#size
		global ivs2 c.diff_wIPT_LMI_CHN_EXCL_IND#size
		global ctrl 
	do "$code/estimation/flexible/decomp_regs_interactions_salaries_bs.do"

	* Set globals:
		global dataspec `data'
		global n = 3
		global rhs1 c.diff_ln_IND#size
		global rhs2 
		global ivs1 c.diff_ln_IVS#size
		global ivs2 
		global ctrl c.diff_wIPT_LMI_CHN_EXCL_IND#size
	do "$code/estimation/flexible/decomp_regs_interactions_salaries_bs.do"

	use "$tempfold/bs2_`data'", clear
	merge 1:1 bs using "$tempfold/bs3_`data'", nogen
	save "$tempfold/cbs", replace
	
	clear
	use "$BS_fold/bsiwage_`data'"
	append using "$tempfold/cbs"
	save "$BS_fold/bsiwage_`data'", replace
}


